<?php
/**
 * 上月
*/

namespace houze\mongodb\query;

class lastmonth {
    /**
     * 构造时间查询
    */
    public static function run($field, $where, $data) {
        $time = strtotime("-1 month");
        $month_start = date('Y-m-01', $time);
        $month_end = date('Y-m-t', $time);

        $start = strtotime($month_start);
        $end = strtotime($month_end)+86399;
        
        return [
            [
                'field' => $field,
                'where' => '>=',
                'value' => $start,
            ],
            [
                'field' => $field,
                'where' => '<',
                'value' => $end,
            ],
        ];
    }
}